package jframe.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import jframe.cache.OscacheFactory;




/**
 * 进行权限认证拦截
 * 1.拦截是否已经登录
 * 2.拦截多访问的URL是否具有操作权限
 * 认证失败直接返回到登录页面
 */
public class AuthorityInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 1L;

	private static final Log log = LogFactory.getLog(AuthorityInterceptor.class);
	
	//静态oscacheFactory
	public static OscacheFactory oscacheFactory ;
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext ctx = invocation.getInvocationContext();
		Map<?,?> session = ctx.getSession();
		//需要扩展
		//session.get("user");	
		log.info(session.get("user"));
		return null;
		
	}

	public static OscacheFactory getOscacheFactory() {
		return oscacheFactory;
	}

	public static void setOscacheFactory(OscacheFactory oscacheFactory) {
		AuthorityInterceptor.oscacheFactory = oscacheFactory;
	}

}
